#include <tinx/syscall.h>
#include <tinx/printf.h>

enum
{
    AT_NULL = 0,    /* end of vector */
    AT_IGNORE,      /* entry should be ignored */
    AT_EXECFD,      /* file descriptor of program */
    AT_PHDR,        /* program headers for program */
    AT_PHENT,       /* size of program header entry */
    AT_PHNUM,       /* number of program headers */
    AT_PAGESZ,      /* system page size */
    AT_BASE,        /* base address of interpreter */
    AT_FLAGS,       /* flags */
    AT_ENTRY,       /* entry point of program */
    AT_NOTELF,      /* program is not ELF */
    AT_UID,         /* real uid */
    AT_EUID,        /* effective uid */
    AT_GID,         /* real gid */
    AT_EGID         /* effective gid */
};

typedef struct Elf32_Auxv
{
    u32 type;
    u32 value;
} _packed Elf32_Auxv;

int main(int argc, char *argv[])
{
    char **envp = argv + argc + 1;
    while (*envp++);

    Elf32_Auxv *auxv = (Elf32_Auxv *)envp;

    while (auxv->type != AT_NULL)
    {
        printf("auxv type %d value 0x%p\n", auxv->type, auxv->value);
        auxv++;
    }

    return 0;
}